package com.platform.modules.report.service;

import com.platform.common.utils.MapUtil;
import com.platform.modules.report.dao.CptAccReportDao;
import com.platform.modules.report.dao.QlyAccReportDao;
import com.platform.modules.report.dto.BaseQueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CptAccReportService {

    @Autowired
    CptAccReportDao cptAccReportDao;

    public Integer cptAccCount(BaseQueryDTO baseQueryDTO) {
        return cptAccReportDao.cptAccCount(baseQueryDTO);
    }

    public Map<String, Object> cptAccCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> cptAccCountList = cptAccReportDao.cptAccCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(cptAccCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> cptAccPrjCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> cptAccCountList = cptAccReportDao.cptAccPrjCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(cptAccCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> cptAccCountGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> cptAccCountList = cptAccReportDao.cptAccCountGroupByYear(baseQueryDTO);
        return MapUtil.flat(cptAccCountList,"YEAR","COUNT");
    }

    public Map<String, Object> cptAccCountGroupByMonth(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> cptAccCountList = cptAccReportDao.cptAccCountGroupByMonth(baseQueryDTO);
        return MapUtil.flat(cptAccCountList,"MONTH","COUNT");
    }

    public Map<String, Object> cptAccCountGroupByPrjCategory(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> list = cptAccReportDao.cptAccCountGroupByPrjCategory(baseQueryDTO);
        return MapUtil.flat(list,"PRJ_CATEGORY","COUNT");
    }
}
